//
//  DHPopPathItem.m
//  BaseProject
//
//  Created by dadahua on 17/5/14.
//  Copyright © 2017年 dahua. All rights reserved.
//

#import "DHPopPathItem.h"


@interface DHPopPathItem ()

//@property (strong, nonatomic) UIImageView *backgroundImageView;
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UIImageView *mImageView;


@end

@implementation DHPopPathItem

+ (instancetype)itemWithTitle:(NSString *)title image:(NSString *)imageName{
    

    CGRect frame = CGRectMake(0, 0, DHPopPathItemWidth, DHPopPathItemHeight);
    return [[self alloc] initWithFrame:frame title:title image:imageName];
}

- (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title image:(NSString *)imageName {
    
    if (self = [super init]) {
        self.frame = frame;
          
        
//        [self setImage:[UIImage imageNamed:imageName]
//              forState:UIControlStateNormal];
//        
//        [self setTitle:title forState:UIControlStateNormal];
//        [self setBackgroundColor:[UIColor redColor]];
        
        
        self.mImageView = ({
            UIImageView *mImageView = [[UIImageView alloc] init];
            mImageView.frame = CGRectMake((DHPopPathItemWidth - kItemImageViewWidth) / 2 ,
                                               0,
                                               kItemImageViewWidth,
                                               kItemImageViewWidth);
            mImageView.image = [UIImage imageNamed:imageName];
            mImageView;
        });

        self.titleLab = ({
            UILabel *lab = [UILabel new];
            lab.frame = CGRectMake(0, CGRectGetMaxY(self.mImageView.frame) + 3, DHPopPathItemWidth, 10);
            lab.text = title;
            lab.textColor = [UIColor whiteColor];
            lab.textAlignment = NSTextAlignmentCenter;
            lab.font = [UIFont systemFontOfSize:8.f];
            lab;
        });
        [self addSubview:self.mImageView];
        [self addSubview:self.titleLab];

    }
    return self;
}

@end
